package com.exam.serviceimpl;
import com.exam.entity.WrongQuestion;
import com.exam.mapper.WrongQuestionRepository;
import com.exam.service.WrongQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class WrongQuestionServiceImpl implements WrongQuestionService {

    @Autowired
    private WrongQuestionRepository wrongQuestionRepository;

    @Override
    public WrongQuestion addWrongQuestion(WrongQuestion wrongQuestion) {
        return wrongQuestionRepository.save(wrongQuestion);
    }

    @Override
    public void deleteWrongQuestion(Long id) {
        wrongQuestionRepository.deleteById(id);
    }

    @Override
    public WrongQuestion getWrongQuestionById(Long id) {
        return wrongQuestionRepository.findById(id).orElse(null);
    }

    @Override
    public Page<WrongQuestion> getAllWrongQuestions(Pageable pageable) {
        return wrongQuestionRepository.findAll(pageable);
    }
}